package testDataGenerator.model;

import org.dom4j.Element;

import testDataGenerator.model.generationMethod.IncrementalMethod;
import testDataGenerator.model.generationMethod.RandomMethod;
import testDataGenerator.model.generationMethod.RangedRandomMethod;

public class GenerationMethodFactory {
	public GenerationMethod createMethod(Element element, String type, DataTypeFactory factory) {
		String name = element.getStringValue();
		if (name.equals("Randomly")) {
			return new RandomMethod(type, factory);
		}
		if (name.equals("Randomly selected from a range")) {
			String low = element.attributeValue("low");
			String high = element.attributeValue("high");
			return new RangedRandomMethod(low, high, type, factory);
		}
		if (name.equals("Incremental")) {
			String start = element.attributeValue("start");
			String step = element.attributeValue("step");
			return new IncrementalMethod(start, step, type, factory);
		}
		return null;
	}

}
